/*
 * I2cDrv.c
 *
 *  Created on: May 13, 2015
 *      Author: mxw
 */

#include <I2cDrv.h>
#include <S3C2440addr.h>

void init_i2c() {
    //select i2cSDA, i2cSCL by configing on GPECON
    rGPECON &= ~0xF0000000;
    rGPECON |= 0xA0000000;

    //remove the mask on ii2
    rINTMSK &= ~(1 << 27);

    //config IICCON
    rIICCON = 0xAF; //enable ACK, iicCLK = fPCLK/16, enable Rx/Tx interupt

    //2440's slave(AT24C02C) address
    rIICADD = 0xA0;

    //configue IICSTAT
    rIICSTAT = 0x10; //enable Rx/Tx

    //confige rIICLC
    rIICLC = 0;
}

int i2c_write_byte(unsigned long addr, unsigned char data){
    return 0;
}

int i2c_read_byte(unsigned long addr, unsigned char* data){
    return 0;
}
